<template>
	<view class="container">
	
		<view class="bg-view">
			<view class="bg_box">
				<!-- 顶部状态栏 -->
				<view class="top-nav"
					:style="'height:' + (titleBarHeight+titleBarHeight) + 'px;position:fixed;top:0;width:100vw;'">
					<view class="status_nav"
						:style="'height:' + statusBarHeight + 'px;position:fixed;top:0;width:100vw;'"></view>
					<view class="left-button-box" :style="'height:'+ titleBarHeight +'px;top:'+ statusBarHeight +'px;'"
						@click="tapToBack('back')">
						<image src="../../static/back.png" mode="aspectFill"></image>
					</view>
					<view
						:style="'height:'+ titleBarHeight +'px;line-height:'+ titleBarHeight + 'px;top:'+ statusBarHeight +'px;position:fixed;width:100vw;'"
						class="Index_tab_top">
						<view class="mine-txt"></view>
					</view>
				</view>
				<view :style="'width: 100vw;height:'+(titleBarHeight+titleBarHeight)+'px;'"></view>
	
			</view>
	
			<image src="https://imgs.ynz666.com/test/2023/08/14/OGYyYzA5ODM0YmJhMWI0MDNjOWQyOTA3OGNhZmVjZTc=.png"
				mode="widthFix" class="bg-image"></image>
			<!-- <view class="title">
				- 本活动最终解释权归下楼科技所有 -
			</view> -->
		</view>
			<view class="cont">

				<view class="main">
					<view class="main_title"></view>
					<view class="main_box">
						<view class="top">
							分享获免单 统统都0元
						</view>
						<view class="bottom">
							<view class="item">1、点击首页轮播，领取免单券</view>
							<view class="item">2、分享页面，赠送好友领取免单券</view>
							<view class="item">3、每赠送一位新朋友领取，均得1张免单券(不设上限)</view>
							<view class="item">4、抵达平台免单商户处消费即可使用免单权益</view>
						</view>
					</view>
					<image
						src="https://imgs.ynz666.com/test/2023/08/10/ZmEyMTMyYTgxNTRiNDA3YzE3ZDkxZDY3OGUxMGEwZjg=.png"
						mode="aspectFill" class="dw"></image>
				</view>
				<view class="main">
					<view class="main_title"></view>
					<view class="main_box">
						<view class="top">
							红包天天领 消费即抵扣
						</view>
						<view class="bottom">
							<view class="item">1、每日进入下楼休闲吧小程序</view>
							<view class="item">2、领取大额红包，红包可累计</view>
							<view class="item">3、抵达平台指定门店即可随机抵扣消费金额</view>
						</view>
					</view>
				</view>
				<view class="main">
					<view class="main_title"></view>
					<view class="main_box">
						<view class="top">
							折扣秒杀团购 超值更优惠
						</view>
						<view class="bottom">
							<view class="item">1、超值团购优惠多，省心省力更省金</view>
							<view class="item">2、进入下楼休闲吧首页</view>
							<view class="item">3、选择购买中意的秒杀/团购</view>
							<view class="item">4、到店出示二维码即可享受福利</view>
							<view class="item">5、消费多少就获得多少积分</view>
						</view>
					</view>
					<image
						src="https://imgs.ynz666.com/test/2023/08/10/ZDRkYmIzMTMyYjFmMWEwNTg0OWNlYjg2OThkNGRjMDI=.png"
						mode="aspectFill" class="dw2"></image>
				</view>
				<view class="main">
					<view class="main_title"></view>
					<view class="main_box">
						<view class="top">
							积分当钱花 省的多赚的多
						</view>
						<view class="bottom">
							<view class="item">1、消费1元获得1积分，1积分=1元钱</view>
							<view class="item">2、进入积分商城，积分可兑换商品或会员卡</view>
							<view class="item">3、兑换的商品及卡券可自用或<text>转售</text></view>
							<view class="item">4、既省钱也赚钱</view>
						</view>
					</view>
					<image
						src="https://imgs.ynz666.com/test/2023/08/10/ZTA3ZTgzNzM4Njg4YzBiOTVmMzc0ODVjODQzNDgyNTk=.png"
						mode="aspectFill" class="dw3"></image>
				</view>
				<view class="main">
					<view class="main_title"></view>
					<view class="main_box">
						<view class="top">
							会员享权益 免单聚划算
						</view>
						<view class="bottom">
							<view class="item">1、购买下楼休闲吧会员卡</view>
							<view class="item">2、成为VIP，享霸王免单权益</view>
							<view class="item">3、更多权益超值享，每年可省更多金</view>
						</view>
						<view class="m_foot">
							<view class="item">
								<image
									src="https://imgs.ynz666.com/test/2023/08/10/MWYyNDczNThiZWFkOThhNzJmY2JhZjY5MDI3NTI2NzA=.png"
									mode="aspectFill" class="img"></image>
								<view class="item_box">
									<view class="v1">
										「39元」3次免单
									</view>
									<view class="v2">
										有效期：90天
									</view>
								</view>
							</view>
							<view class="item">
								<image
									src="https://imgs.ynz666.com/test/2023/08/10/YTM1NTI2ZDgzOWRmZDljMmRkZTcyNWE3ODhmMTk0OGU=.png"
									mode="aspectFill" class="img"></image>
								<view class="item_box">
									<view class="v1">
										「99元」12次免单
									</view>
									<view class="v2">
										有效期：90天
									</view>
								</view>
							</view>
							<view class="item">
								<image
									src="https://imgs.ynz666.com/test/2023/08/10/ZWQ3ZDdkODgzOTBiZGI4Mzc2YzVmMDUyNWNiM2Q0MzA=.png"
									mode="aspectFill" class="img"></image>
								<view class="item_box">
									<view class="v1">
										「199元」30次免单
									</view>
									<view class="v2">
										有效期：90天
									</view>
								</view>
							</view>
							<view class="item">
								<image
									src="https://imgs.ynz666.com/test/2023/08/10/YWZhNWQwODNjN2YwMjI2OGM0MjA3MDMzZWUxMmMwNDM=.png"
									mode="aspectFill" class="img"></image>
								<view class="item_box">
									<view class="v1">
										「499元」90次免单
									</view>
									<view class="v2">
										有效期：90天
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="foot" @click="jumpIndex">
				进入下楼休闲吧
			</view> -->
				<view class="foot">
					<view class="btn">
						<view class="btn_box" v-if="myInfo.status==0" @click="drawDown">
							<view class="view1">
								立即领取
							</view>
						</view>
						<view class="btn_box" v-if="myInfo.status!=0">
							<view class="view1">
								立即赠送
							</view>
							<!-- <text class="text1">（分享朋友即可获得）</text> -->
							<button open-type="share" class="btn_sha"></button>
						</view>
						<button v-if="!mineInfo.phone && mineInfo.phone.length!==11" open-type="getPhoneNumber"
							class="btn_pho" @getphonenumber.stop="onGetPhoneNumber"></button>
					</view>

					<!-- <view class="text" @click="jumpPage">
					查看我分享的人
				</view> -->
				</view>
			</view>




		</view>
</template>

<script>
	var app = getApp();
	import http from '@/utils/request/http.js';
	import env from '@/env/index.js';


	import {
		getInviteLatest,
		getShareInvitePage,
		apiEmbeddingPointAdd
	} from '../../apis/index.js';
	export default {
		data() {
			return {
				statusBarHeight: 0,
				titleBarHeight: 0,
				bottomTabbar: 0,
				menuButtonInfo: {},
				mineInfo: {},

				parentUid: '', //链接分享上一级id
				agentId: '', //逍客的ID


				myInfo: {},
			}
		},
		onShareAppMessage(res) {
			return {
				title: '吃喝玩乐福利多，会员权益享不停',
				imageUrl: '',
				path: `/pageD/memberEquity/memberEquity?parentUid=${this.mineInfo.id}`
			}
		},
		onLoad(options) {
			console.log(options, "options")
			
			if (options.parentUid) {  
				this.parentUid = options.parentUid
			}

			if (options.agentId) {
				this.agentId = options.agentId
			}
			
		},
		onShow() {
			let that = this
			that.LoginInvite();

		},
		onReady() {
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			this.titleBarHeight = (uni.getMenuButtonBoundingClientRect().top - this.statusBarHeight) * 2 + uni
				.getMenuButtonBoundingClientRect().height;
			this.bottomTabbar = uni.getStorageSync('bottomTabbar');
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
		},
		methods: {
			// 埋点
			addPoint({
				id,
				pointCode,
				eventTitle,
				eventCode,
				eventContent,
				pointReason,
				pointType = [8]
			}) {
				let data={
					id,
					pointCode, // 埋点编号
					lastPageCode: 1001, // 上一页页面编号
					pageCode: 1001, // 当前页编号
					pageTitle: '会员权益享不停', // 页面标题
					eventTitle, // 事件标题
					eventCode, // 事件编号
					eventContent, // 事件说明
					pointReason, // 埋点原因
					pointType
				}
				apiEmbeddingPointAdd(data).then(res=>{
					
				})
				// app.httpRequest({
				// 	url: app.globalData.baseUrl + '/api/user/v1/embedding/point/add',
				// 	data: {
				// 		id,
				// 		pointCode, // 埋点编号
				// 		lastPageCode: 1001, // 上一页页面编号
				// 		pageCode: 1020, // 当前页编号
				// 		pageTitle: '抽奖有礼', // 页面标题
				// 		eventTitle, // 事件标题
				// 		eventCode, // 事件编号
				// 		eventContent, // 事件说明
				// 		pointReason, // 埋点原因
				// 		pointType
				// 	}
				// }).then(res => {})
			},
			// 返回按钮
			tapToBack(page) {
				switch (page) {
					case 'index':
						uni.switchTab({
							url: '/pages/index/index'
						})
						break;
					case 'back':
						console.log(111)
						uni.navigateBack({
							delta: 1,
							fail() {
								console.log(222)
								uni.switchTab({
									url: '/pages/index/index'
								})
							}
						})
						break;
				}
			},
			jumpIndex() {
				uni.switchTab({
					url: '/pages/index/index',
				})
			},
			getShareInvitePageInfo() {
				getShareInvitePage().then(res => {
					this.myInfo = res.data
				})
			},
			LoginInvite(login) {
				let that = this;
				let inviteId = null;
				app.isLogin({
					id: inviteId
				}, function(res) {
					that.mineInfo = res;
					if (that.parentUid) {
						that.addPoint({
							id: 1002,
							pointCode: 'xiu-002',
							eventTitle: '通过别人分享进入权益分享页面',
							eventCode: 'share-equity',
							eventContent: '通过别人分享进入权益分享页面',
							pointReason: '统计用户通过分享权益进入的路径的次数'
						})
					}else{
						that.addPoint({
							id: 1001,
							pointCode: 'xiu-001',
							eventTitle: '通过小程序码进入权益分享页面',
							eventCode: 'share-ewm-equity',
							eventContent: '通过小程序码进入权益分享页面',
							pointReason: '统计用户小程序码进来入权益分享页面的次数'
						})
						
					}
					that.getShareInvitePageInfo();
					console.log(that.mineInfo, "that.mineInfo")
				});
			},
			// 手机号授权
			onGetPhoneNumber(e) {
				let that = this;
				app.GetMobile(e, function(e) {
					app.getUserInfo(function(lRes) {
						that.mineInfo = lRes;
						that.drawDown();
					})
				});
			},
			// 立即领取
			drawDown() {
				let data = {
					parentUid: this.parentUid,
					uid: '',
					agentId: this.agentId,
				}
				getInviteLatest(data).then(res => {
					console.log(res, "res")
					if (res.code == 200) {
						uni.showToast({
							title: '你已领取成功',
							icon: "none"
						})
						this.myInfo.status = 1
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.left-button-box {
		display: flex;
		align-items: center;
		position: absolute;
		left: 30rpx;
		z-index: 7;
	
		.line {
			height: 30rpx;
			background: #CCCCCC;
			width: 1rpx;
		}
	
		image {
			width: 30rpx;
			height: 30rpx;
			margin: 0 20rpx;
		}
	}
	/* 背景 */
	.bg-view {
		width: 100vw;
		height: 1100rpx;

		.bg_box {
			height: 1100rpx;
			// background: linear-gradient(180deg, #F77539 0%, #FEFDFB 100%);
		}

		.bg-image {
			z-index: -1;
			display: block;
			width: 100%;
			height: 1100rpx;
			position: absolute;
			top: 0;
			left: 0;
		}
	}

	.cont {
		width: 100%;
		// height: 2845rpx;
		padding-bottom: 150rpx;
		background: linear-gradient(90deg, #FC5439 0%, #FD663F 100%);
		margin-top: -95rpx;

		.main {
			margin: 0 40rpx 40rpx;
			padding-bottom: 22rpx;
			background: #FFE7C4;
			border-radius: 20rpx;
			position: relative;

			.main_title {
				height: 20rpx;
			}

			.main_box {
				width: 630rpx;
				background: #FFF7EC;
				box-shadow: 0px 0px 5rpx 0px #FFE08E;
				border: 1rpx solid #FDD45D;
				margin: 0 20rpx;
				padding-bottom: 28rpx;

				.top {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 340rpx;
					height: 68rpx;
					background: #FF5B40;
					border-radius: 0px 0px 10rpx 10rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					margin-left: 145rpx;
				}

				.bottom {
					margin: 44rpx 44rpx 0;
					line-height: 50rpx;

					.item {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;

						text {
							font-weight: bold;
							color: rgba(253, 59, 62, 1);
						}
					}
				}

				.m_foot {
					margin: 30rpx 44rpx 0;
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;

					.item {
						width: 242rpx;
						height: 240rpx;
						background: #FFFFFF;
						border-radius: 20rpx;
						overflow: hidden;
						display: flex;
						flex-direction: column;
						margin-bottom: 40rpx;

						.img {
							width: 100%;
							height: 144rpx;
						}

						.item_box {
							width: 100%;
							height: 96rpx;
							background: #FFFFFF;

							.v1 {
								font-size: 24rpx;
								font-family: PingFangSC-Medium, PingFang SC;
								font-weight: 500;
								color: #E64E1F;
								padding: 17rpx 10rpx 0;
							}

							.v2 {
								font-size: 21rpx;
								font-family: PingFangSC-Medium, PingFang SC;
								font-weight: 500;
								color: rgba(102, 102, 102, 1);
								padding: 4rpx 10rpx 0;
							}
						}
					}
				}
			}

			.dw {
				width: 112rpx;
				height: 105rpx;
				position: absolute;
				left: -28rpx;
				bottom: -45rpx;
				z-index: 10;
			}

			.dw2 {
				width: 107rpx;
				height: 96rpx;
				position: absolute;
				right: -28rpx;
				top: -28rpx;
				z-index: 10;
			}

			.dw3 {
				width: 124rpx;
				height: 118rpx;
				position: absolute;
				left: -39rpx;
				bottom: -45rpx;
				z-index: 10;
			}
		}
	}

	.foot {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-top: 32rpx;
		// padding-bottom: 52rpx;
		position: fixed;
		bottom: 50rpx;

		.btn {
			width: 520rpx;
			height: 120rpx;
			font-size: 48rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #F43B00;
			position: relative;

			.btn_box {
				width: 520rpx;
				height: 120rpx;
				background: linear-gradient(180deg, #FCDF8D 0%, #FC952C 100%);
				border-radius: 60rpx;
				border: 2rpx solid #FFFFFF;
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;

				.view1 {}

				.text1 {
					font-size: 22rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
				}

				.btn_sha {
					width: 520rpx;
					height: 120rpx;
					border-radius: 28rpx 0px 0px 28rpx;
					position: absolute;
					top: 0;
					left: 0;
					opacity: 0;
					border: 1rpx solid red;
				}
			}
		}

		.btn_pho {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;
			opacity: 0;
		}

		.text {
			font-size: 24rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			margin-top: 16rpx;
			text-decoration: underline;
		}
	}
</style>
